package cn.yhjz.platform.system.controller;


import cn.yhjz.common.AjaxResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

//@Controller
@Slf4j
@RequestMapping({"${server.error.path:${error.path:/error}}"})
public class GlobalErrorController implements ErrorController {

    @RequestMapping(produces = {"text/html"})
    @ResponseBody
    public String errorHtml(HttpServletRequest request, HttpServletResponse response) {
        return "系统异常，请联系管理员";
    }
    @RequestMapping
    @ResponseBody
    public AjaxResponse error(HttpServletRequest request) {
        return AjaxResponse.fail("系统异常，请联系管理员");
    }
}
